package com.wavehi.servlet;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @Author WaveHi
 * @Date 13/9/2021 上午 11:20
 * @Version 1.0
 * @Contact HJBWaveHi@163.com
 * @Description
 */
public class MyThirdServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("I am thirdServlet!");
        response.setContentType("UTF-8");
        //获取输出流
        PrintWriter writer = response.getWriter();
        writer.write("This is my answer!");
        writer.flush();
        //设置字符集
//        response.setContentType("GBK");
//        //设置响应码
//        response.setStatus(200);
//        //请求重定向
//        response.sendRedirect(getServletContext().getRealPath("myFirstServlet"));
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("I am thirdServlet!");

    }
}
